package main;

import model.GameRecord;
import model.GameState;
import model.GameType;
import org.apache.log4j.Logger;
import util.Bag;
import util.GameLoader;

import java.io.IOException;
import java.util.List;

/**
 * @author Alex Vikharev vikharev@yandex-team.ru
 *         created 25.02.12
 */
public class Statistics {
    private static final Logger log = Logger.getLogger(Statistics.class);
    
    private static void printStatistics(List<GameRecord> data){
        Bag<String> counter = new Bag<>(true);
        for (GameRecord gameRecord : data) {
            if(gameRecord.getResult() == GameState.FIRST_PLAYER_WIN){
                counter.put("First player wins: ");
            } else if(gameRecord.getResult() == GameState.SECOND_PLAYER_WIN){
                counter.put("Second player wins: ");
            } else {
                counter.put("Ties: ");
            }

            counter.put("Parties of length " + gameRecord.getMovesCount());
        }
        for (String key : counter) {
            System.out.println(key + " " + counter.get(key));
        }
    }

    public static void main(String[] args) throws IOException, InterruptedException {
        printStatistics(GameLoader.load("LightLookAhead(3x2)games100000", GameType.IMPROVED));
    }
    
}
